﻿using System;
using System.Xml.Serialization;
using System.Globalization;

namespace TwitterWrapper.Resources
{
    [XmlType(TypeName = "status")]
    public class Status
    {
        private const string TwitterDateFormat = "ddd MMM dd HH:mm:ss zzzzz yyyy";

        [XmlElement("created_at")]
        public string Created { get; set; }
        [XmlElement("id")]
        public long Id { get; set; }
        [XmlElement("text")]
        public string Text { get; set; }

        public DateTime CreatedDate()
        {
            DateTime result;
            return DateTime.TryParseExact(Created, TwitterDateFormat, CultureInfo.InvariantCulture,
                                          DateTimeStyles.AdjustToUniversal, out result) ? result : new DateTime();
        }
    }
}
